<template>
  <div class="hidden-scrollbar">
    <!-- 左上角返回按钮 -->
    <back-arrow style="z-index: 20;"></back-arrow>
    <!-- 顶部占位导航条 -->
    <div class="cinema-info-navbar"></div>
    <template v-if="cinemaInfo">
      <!-- 标题 -->
      <div class="cinema-header-title" style="margin-bottom: 15px;">{{ cinemaInfo.name }}</div>
      <!-- 地址 -->
      <div class="cinema-address-tel-offline">
        <div class="cinema-address-tel-left-offline"><i class="iconfont icon-weizhi"></i>{{ cinemaInfo.address }}</div>
        <div class="cinema-address-tel-right-offline"><i class="iconfont icon-you"></i></div>
      </div>
      <!-- 电话 -->
      <div class="cinema-address-tel-offline" style="border-bottom: 1px solid #f4f4f4;">
        <div class="cinema-address-tel-left-offline"><img src="@/assets/images/tel-icon.png"
               alt="tel-icon">{{ cinemaInfo.phone }}</div>
        <div class="cinema-address-tel-right-offline"><i class="iconfont icon-you"></i></div>
      </div>
      <!-- 服务 -->
      <ul class="service-list" style="margin-top: 10px;" v-if="cinemaInfo.services">
        <li v-for="(item, index) in cinemaInfo.services" :key="index">
          <div class="service-item-left">
            <span>{{ item.name }}</span>
          </div>
          <div class="service-item-right">
            {{ item.description }}
          </div>
        </li>
      </ul>
    </template>
  </div>
</template>

<script>
import { load, getTimestamp } from '@/utils'
import BackArrow from '@/components/BackArrow'

export default {
  name: 'CinemaOffline',
  props: ['cinemaId'],
  components: { BackArrow },
  data () {
    return {
      cinemaInfo: null
    }
  },
  mounted () {
    load({
      url: `/gateway/?cinemaId=${this.cinemaId}&k=${getTimestamp()}`,
      headers: { 'X-Host': 'mall.film-ticket.cinema.info' }
    })
      .then((res) => {
        this.cinemaInfo = Object.freeze(res.data.data.cinema)
      })
      .catch((err) => {
        console.warn(err)
        this.cinemaInfo = null
      })
  }
}
</script>

<style lang="scss" scoped>
.cinema-info-navbar {
  height: 44px;
  background-color: white;
  position: sticky;
  top: 0;
}
.cinema-header-title {
  height: 44px;
  line-height: 44px;
  text-align: center;
  font-size: 17px;
  background-color: white;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.service-list {
  padding: 0px 25px;
  display: flex;
  flex-direction: column;
  li {
    display: flex;
    margin-top: 20px;
    .service-item-left {
      width: 25vw;
      font-size: 12px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      span {
        color: #ffb232;
        display: inline-block;
        border: 1px solid #ffb232;
        border-radius: 2px;
        padding: 0 6px;
      }
    }
    .service-item-right {
      width: 75vw;
      color: #797d82;
      font-size: 12px;
    }
  }
}
.cinema-address-tel-offline {
  min-height: 50px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-top: 1px solid #f4f4f4;
  box-sizing: border-box;
  .cinema-address-tel-left-offline {
    width: 90vw;
    padding-left: 18px;
    display: flex;
    align-items: center;
    i,
    img {
      width: 18px;
      height: 18px;
      color: #797d82;
    }
    i {
      display: block;
      font-size: 20px;
      margin-right: 10px;
    }
    img {
      margin-right: 8px;
      margin-left: 2px;
    }
  }
  .cinema-address-tel-right-offline {
    width: 10vw;
    display: flex;
    justify-content: center;
    i,
    img {
      font-size: 12px;
    }
  }
}
</style>
